<?php 
	include "restritoCliente.php";
	if (!isset($_SESSION)){
		session_start();
	}
	header("Content-Type: text/html; charset=UTF-8", true);
?>

<?php

include_once "ProductControl.php";

 $product = ProductControl::getProdutoOficial($idProduct);

?>
<form class="join-form" name="detalhesPedido"  enctype="multipart/form-data" method="POST" action="acaoInserirCarrinho.php?idProduct=<?php echo $product->Id;?>">
			
		<span class="highlights">Detalhes</span>
        
        <div id-"carousel" >
        	<div id="welcomeHero">
			
		<div id="slideshow-main">
			<ul>
				<?php 			  
			  	$count = 1;
			  	if($product->Fotos != null)
			  	foreach ($product->Fotos as $photo){
			  			  
			  	$file = "imagensBanco/photo".$product->Id."-". $count . $product->Fotos[$count-1][1];
			  	if(file_exists($file)) @unlink($file);
			  	$fp = fopen($file, "a");
			  	$escreve = fwrite($fp, $product->Fotos[$count-1][0]);
			  
			  	fclose($fp);
			  	if($count == 1)
			  		echo '<li class="p1 active">';
			  	else
			  	echo '<li class="p'.$count.'">'; 
			  	echo'<a href="#"><img src="'.$file.'" width="361" height="240" alt=""/></a>	</li>';
			  		$count++;
			  	}
			  
			  	if($count == 1)
			  	{
			  		$file = "imagensBanco/imagemIndisponivel.bmp";
			  		echo '<li class="p1 active"> <a href="#"><img src="'.$file.'" width="361" height="240" alt=""/></a>	</li>';
			  	}
			  
			  ?>
				
			</ul>										
		</div>
				
		<div id="slideshow-carousel">		
        
        <!--IMPORTANTE, OS TAMANHOS DAS IMAGENS DEVEM SER MANTIDOS AQUI-->		
			  <ul id="carousel" class="jcarousel jcarousel-skin-tango">

			  <?php 
			  
			  	$count = 1;
			  	if($product->Fotos != null)
			  	foreach ($product->Fotos as $photo){
			  			  
			  	$file = "imagensBanco/photo".$product->Id."-". $count . $product->Fotos[$count-1][1];
			  	if(file_exists($file)) @unlink($file);
			  	$fp = fopen($file, "a");
			  	$escreve = fwrite($fp, $product->Fotos[$count-1][0]);
			  
			  	fclose($fp);
			  	echo '<li><a href="#" rel="p'.$count.'"><img src="'.$file.'" width="60" height="60" alt="#"/></a><a href="#"';
			  	if($count == 1)
			  		echo ' rel="p1 active"></a></li>';
			  		else 
			  	echo ' rel="p'.$count.'"></a></li>';
			  	
			  		$count++;
			  	}
			  
			  	if($count == 1)
			  	{
			  		$file = "imagensBanco/imagemIndisponivel.bmp";
			  		echo '<li><a href="#" rel="p1 active"><img src="'.$file.'" width="60" height="60" alt="#"/></a><a href="#" rel="p1 active"></a></li>';
			  	}
			  
			  ?>
			  </ul>
		</div>
		
		<div class="clear"></div>
		
	</div>

        	
   </div>
        
   <div id="titulo_produto">
   <h2> <?php echo $product->Nome;?></h2>
	<p><?php echo implode(', ', $product->Categoria); ?></p>
    <h4>Último orçamento:</h4>   
    <h3><?php echo $product->UltimoPreco;?></h3>
    <input type="image" src="images/botaoAdicionar.png" />
   </div>     
        
   <div id="descricao_produto">
   		<p><?php echo $product->Descricao;?></p>
   </div>
        
</form>